package com.cqu.apptest.service.impl;

import com.cqu.apptest.VirtualDB.UserDatabase;
import com.cqu.apptest.pojo.User;
import com.cqu.apptest.service.UserService;
import com.cqu.springmvc.annotation.Service;

import java.util.List;

@Service //默认类名首字母小写 userServiceImpl
public class UserServiceImpl implements UserService {

    @Override
    public List<User> findUsers() {
        UserDatabase userDatabase = new UserDatabase();
        List<User> users = userDatabase.getUsers();
        return users;
    }

    @Override
    public String queryUserByName(String name){
        String msg = "UserDatabase中不存在该用户!";
        UserDatabase userDatabase = new UserDatabase();
        List<User> users = userDatabase.getUsers();
        for(User user : users){
            if(user.getName().equals(name)){
                msg = name+"在UserDatabase中!";
            }
        }
        return msg;
    }
}
